import {
  saveMeta,
  saveNote,
  deleteMeta,
  deleteNote,
  pageMeta,
  pageNote,
  levelUp,
  reOpen,
  listNeedReview
} from '@/services/BookNote';
import {setAuthority} from "@/utils/authority";


const BookNoteModel = {
  namespace: 'bookNote',
  state: {notePage: null},
  effects: {
    * saveMeta({payload}, {call, put}) {
      const response = yield call(saveMeta, payload);
      yield put({
        type: 'saveMetaRes',
        payload: response,
      });
    },
    * saveNote({payload}, {call, put}) {
      const response = yield call(saveNote, payload);
      yield put({
        type: 'saveNoteRes',
        payload: response,
      });
    },
    * deleteMeta({payload}, {call, put}) {
      const response = yield call(deleteMeta, payload);
      yield put({
        type: 'deleteMetaRes',
        payload: response,
      });
    }, * deleteNote({payload}, {call, put}) {
      const response = yield call(deleteNote, payload);
      yield put({
        type: 'deleteNoteRes',
        payload: response,
      });
    },
    * pageMeta({payload}, {call, put}) {
      const response = yield call(pageMeta, payload);
      yield put({
        type: 'pageMetaRes',
        payload: response,
      });
    },
    * pageNote({payload}, {call, put}) {
      const response = yield call(pageNote, payload);
      yield put({
        type: 'pageNoteRes',
        payload: response,
      });
    },
    * levelUp({payload}, {call, put}) {
      const response = yield call(levelUp, payload);
      yield put({
        type: 'levelUpRes',
        payload: response,
      });
    },
    * reOpen({payload}, {call, put}) {
      const response = yield call(reOpen, payload);
      yield put({
        type: 'reOpenRes',
        payload: response,
      });
    },
    * listNeedReview({payload}, {call, put}) {
      const response = yield call(listNeedReview, payload);
      yield put({
        type: 'listNeedReviewRes',
        payload: response,
      });
    }
  },
  reducers: {
    saveMetaRes(state, {payload}) {
      return {...state, ...payload};
    },
    saveNoteRes(state, {payload}) {
      return {...state, ...payload};
    },
    deleteMetaRes(state, {payload}) {
      return {...state, ...payload};
    },
    deleteNoteRes(state, {payload}) {
      return {...state, ...payload};
    },
    pageMetaRes(state, {payload}) {
      return {...state, ...payload};
    },
    pageNoteRes(state, {payload}) {
      return {notePage:payload};
    }, levelUpRes(state, {payload}) {
      return {...state, ...payload};
    }, reOpenRes(state, {payload}) {
      return {...state, ...payload};
    },
    listNeedReviewRes(state, {payload}) {

      return {notePage:payload};

    },
  }
}
export default BookNoteModel;
